<%@ include file = "/common/ini.jsp"%>
<%@ include file = "/common/_log4j.jsp"%>
<%@ include file = "/common/_ApplicationContext_init.jsp"%>
<%@ include file = "/common/_vr.jsp"%>
<%@ include file = "/js/_js_for_select.jsp"%>
<%
    // 定义名称
    String title = "修改类别";
    TypeManager typeManager = (TypeManager)applicationContext.getBean("typeManager");
    Type type = (Type)typeManager.get(request.getParameter("id"));
%>
<script>
    function submitData()
    {
        detailForm.serviceURL.value = "basedata.type.UpdateTypeService";
        detailForm.submit();
    }
    function reset()
    {
        delAllOptions(detailForm.parentId);
        addOption(detailForm.parentId,"null","无");
        detailForm.id.value="<%= type.getId()%>";        
        <%
        String remark = "";
        String parentId = null;
        if(vr.isAllValidated())    
        {
            if(type.getSuperType() != null)
            {
                parentId = type.getSuperType().getId();
                %>addOption(detailForm.parentId,"<%= type.getSuperType().getId()%>","<%= type.getSuperType().getName()%>");<%
            }
            %>
			detailForm.code.value = "<%= type.getCode()%>";
            detailForm.id.value = "<%= type.getId()%>";
            detailForm.name.value = "<%= type.getName()%>";
            detailForm.parentId.value = "<% if(type.getSuperType() != null) out.print(type.getSuperType().getId());%>";
            detailForm.remark.value = tempRemark.value;
            <%
            remark = type.getRemark();
        }
        else
        {
            if(request.getParameter("parentId") != null)
            {
                Type superType = (Type)typeManager.get(request.getParameter("parentId"));
                parentId = superType.getId();
                %>addOption(detailForm.parentId,"<%= superType.getId()%>","<%= superType.getName()%>");<%
            }
            %>
			detailForm.code.value = "<%= request.getParameter("code")%>";
            detailForm.id.value = "<%= request.getParameter("id")%>";
            detailForm.name.value = "<%= request.getParameter("name")%>";
            detailForm.parentId.value = "<%= request.getParameter("parentId")%>";
            detailForm.remark.value = tempRemark.value;
            <%
            remark = request.getParameter("remark");
        }    
        %>
    }
    function addSubType()
    {
        window.location.href = "<%= request.getContextPath()%>/moduleinfor/basedata/type/addType.jsp?parentId=<%= type.getId()%>";
    }

    function bodyLoadJS()
    {
        // 被聚焦的控件
        detailForm.parentId.focus();
    }
</script>
<%@ include file = "/common/detail/_OnForm.jsp"%> 
<%@ include file = "_detail.jsp"%> 
<%@ include file = "/common/detail/_UnderFom_OnButton.jsp"%>
          <input  type="button" value="提交" afterFocused="" of="true" onclick="submitData()">
          &nbsp;&nbsp;<input  type="button" onclick="addSubType()" value="添加子类别">
          &nbsp;&nbsp;<input  type="button" onclick="reset()" value="重置">
          &nbsp;&nbsp;<input  type="button" onclick="goback()" value="返回">
<%@ include file = "/common/detail/_UnderFom_underButton.jsp"%>
